home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flopen -- Open a file
- *
- * Synopsis ercode = flopen(pfile,phandle,access);
- * int ercode Returned DOS error code
- * char *pfile File path name
- * int *phandle File handle associated with the file
- * int access File access code
- *
- * Description This function opens a file with the specified file path
- * name are returns a file handle with which the file may
- * be accessed. The file is opened with access rights
- * specified in the access code:
- *
- * 0 - Open for reading only
- * 1 - Open for writing only
- * 2 - Open for reading and writing.
- *
- * Returns ercode DOS 2.0 function error code
- * phandle Associated file handle. If an error is
- * encountered, -1 is returned.
- *
- * Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
- *
- **/
- #include <compiler.h>
-
- #define utbyword(a,b) (((a)<<8)|((b)&0x00ff)) /* a is high, b low */
-
- struct dreg
- {
- unsigned ax,bx,cx,dx,si,di,ds,es;
- };
- #define DOSREG struct dreg
-
- int flopen(pfile,phandle,access)
- char *pfile;
- int *phandle,access;
- {
-
- DOSREG dos_reg;
- int ercode,dos(),utinit();
- #if CI201A & LDATA
- unsigned long ptrtoabs();
- #endif
-
- utinit(&dos_reg); /* Initialize registers */
- dos_reg.ax = utbyword(0x3d,access);
- #if LDATA
- #if CI201A
- dos_reg.ds = (unsigned)((ptrtoabs(pfile) & 0xffff0L) >> 4L);
- dos_reg.dx = (unsigned)(ptrtoabs(pfile) & 0xfL);
- #else
- dos_reg.ds = (unsigned)(((long)(pfile) & 0xffff0L) >> 4L);
- dos_reg.dx = (unsigned)((long)(pfile) & 0xfL);
- #endif
- #else
- dos_reg.dx = (unsigned)pfile;
- #endif
-
- ercode = dos(&dos_reg);
- if (ercode == 0)
- *phandle = dos_reg.ax;
- else
- *phandle = -1;
-
- return(ercode);
-
- }